package com.gxc.service.user.feign;

import com.gxc.service.common.model.ServerResponse;
import com.gxc.service.user.model.dto.GetFeignTestDto;
import com.gxc.service.user.model.dto.ProductDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author GongXincheng
 * @since 2019-11-08 21:57
 */
@FeignClient(value = "${gxc.service.goods-service}", fallbackFactory = GoodsFeignFallbackFactory.class)
public interface GoodsFeign {

    /**
     * 批量新增
     */
    @GetMapping("/product/add")
    ServerResponse<List<ProductDto>> add();

    /**
     * 根据id查询.
     */
    @GetMapping("/product/{id}")
    ServerResponse<ProductDto> findById(@PathVariable Long id);

    /**
     * 模糊查询
     */
    @GetMapping("/product/search")
    ServerResponse<List<ProductDto>> likeSearch(@RequestParam String name);

    /**
     * 保存
     */
    @PostMapping("/product/save")
    ServerResponse<ProductDto> save(@RequestBody ProductDto entity);

    /**
     * 测试feign 调用get请求.
     */
    @GetMapping("/product/feign/get-test")
    ServerResponse<GetFeignTestDto> feignGetTest(@SpringQueryMap GetFeignTestDto dto);
}
